package com.fight.strive.sys.modules.cauth.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fight.strive.sys.modules.cauth.entity.AppClientEntity;
import com.fight.strive.sys.modules.cauth.service.AppClientService;
import com.fight.strive.sys.modules.common.PageR;
import com.fight.strive.sys.modules.common.ReStatus;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/admin/sys/cauth")
public class AppClientController {

    @Resource
    private AppClientService appClientService;

    @PostMapping("/save")
    public ReStatus<Void> saveAppClient(@RequestBody AppClientEntity entity) {
        appClientService.saveAppClient(entity);
        return ReStatus.success();
    }

    @PostMapping("/list")
    public ReStatus<IPage<AppClientEntity>> getByPage(
            @RequestBody PageR<AppClientEntity> page) {
        return ReStatus.success(appClientService.listByPage(page));
    }

    @PostMapping("/remove")
    public ReStatus<Void> remove(
            @RequestBody AppClientEntity entity) {
        appClientService.removeAppClient(entity);
        return ReStatus.success();
    }

    @RequestMapping("/get/{id}")
    public ReStatus<AppClientEntity> get(@PathVariable String id) {
        return ReStatus.success(
                appClientService.getById(id));
    }
}
